package com.glory.dgcpcpda.adapter;

import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.fragment.app.FragmentManager;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.glory.dgcpcpda.R;
import com.glory.dgcpcpda.activity.cpc.WforMaterialViewActivity;
import com.glory.dgcpcpda.base.Constant;
import com.glory.dgcpcpda.callback.CustomDialogEntityCallBack;
import com.glory.dgcpcpda.entity.AdrefListEntity;
import com.glory.dgcpcpda.entity.EywEqpUploadWaitEntity;
import com.glory.dgcpcpda.entity.LotInfoEntity;
import com.glory.dgcpcpda.entity.LotList;
import com.glory.dgcpcpda.entity.response.BaseResponseBean;
import com.glory.dgcpcpda.utils.LotUtils;
import com.glory.dgcpcpda.utils.NetUtils;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.model.Response;
import com.pda.platform.ui.ui_pdaplatform.callback.FreeUI_DialogEntityCallBack;
import com.pda.platform.ui.ui_pdaplatform.callback.FreeUI_EntityCallBack;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_DialogUtils;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_LogUtils;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_ToastUtils;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;


public class NewWForMaterialListAdapter extends BaseQuickAdapter<EywEqpUploadWaitEntity, BaseViewHolder> {

    private Context mContext;
    public List<EywEqpUploadWaitEntity> deleteData;

    public NewWForMaterialListAdapter(@Nullable List<EywEqpUploadWaitEntity> data, Context context) {
        super(R.layout.adapter_new_wformaterial,data);
        this.mContext = context;
        this.deleteData = new ArrayList<>();
    }

    @Override
    protected void convert(BaseViewHolder helper, EywEqpUploadWaitEntity item) {
        helper.setText(R.id.tvPlace, item.getPLACE());//设备区域编号
        helper.setText(R.id.tvEqpID, item.getEQP_PLACEMENT());//设备位置号
        helper.setText(R.id.tvPackageType, item.getPACKAGETYPE());//封装形式
        helper.setText(R.id.tvBDID, item.getDB_ID());//BD图

        TextView tvBaseSubmit = helper.getView(R.id.tvBaseSubmit);
//        TextView tvClose = helper.getView(R.id.tvClose);

        if(!StringUtils.isNoneEmpty(item.getCRAGO_INFORMATION())){
            tvBaseSubmit.setVisibility(View.INVISIBLE);
        }
        else {
            tvBaseSubmit.setVisibility(View.VISIBLE);
        }
        tvBaseSubmit.setOnClickListener(view -> {
            showitem(item);
        });

//        tvClose.setOnClickListener(view -> {
//            colseitem(item);
//        });

        CheckBox checkbox = helper.getView(R.id.checkbox);

        checkbox.setChecked(false);
        checkbox.setOnCheckedChangeListener((compoundButton, b) -> {
            if (b){
                deleteData.add(item);
            }else {
                deleteData.remove(item);
            }
        });
    }

    private void showitem(EywEqpUploadWaitEntity item){
        String bd =item.getDB_ID();
        Intent intent = new Intent(mContext, WforMaterialViewActivity.class); // 替换NewActivity为你的目标Activity
        intent.putExtra("item", item.getCRAGO_INFORMATION()); // 将数据作为Serializable对象传递
        mContext.startActivity(intent); // 假设mContext是你的Activity或Fragment的上下文
    }
}
